package org.boot.ssm.wxshop.web.Interceptor;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * @program: wxshop
 * @description: 拦截器配置
 * @author: 刘涛
 * @create: 2018-03-25 19:59
 **/
@Configuration
public class WebAppConfigurer extends WebMvcConfigurerAdapter {

    @Bean
    public HandlerInterceptor getMyInterceptor() {
        return new FrontstageInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // addPathPatterns 用于添加拦截规则,
        // excludePathPatterns 用户排除拦截

        registry.addInterceptor(getMyInterceptor()).addPathPatterns("/user/frontstage/**")
                .addPathPatterns("/shopcar/front/**").addPathPatterns("/orderInfo/frontstage/**")
                .excludePathPatterns("/user/frontstage/goRegistPage")
                .excludePathPatterns("/user/frontstage/getDynamicNum")
                .excludePathPatterns("/user/frontstage/registUser")
                .excludePathPatterns("/frontstage/login")
        ;
        super.addInterceptors(registry);
    }


}
